package com.gnerv.sylvanas.authentication.security.model;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.security.core.CredentialsContainer;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.HashMap;
import java.util.Set;

/**
 * @author Gnerv LiGen
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class AccountDetails extends HashMap<String, Object> implements UserDetails, CredentialsContainer {

    private String ukId;
    private String username;
    private String password;
    private String status;

    private Set<GrantedAuthority> authoritiesList;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authoritiesList;
    }

    @Override
    public void eraseCredentials() {
        this.password = null;
    }

    @Override
    public boolean isAccountNonExpired() {
        return UserDetails.super.isAccountNonExpired();
    }

    @Override
    public boolean isAccountNonLocked() {
        return UserDetails.super.isAccountNonLocked();
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return UserDetails.super.isCredentialsNonExpired();
    }

    @Override
    public boolean isEnabled() {
        return UserDetails.super.isEnabled();
    }
}